package Leetcode第一期;

/**
 * @author : K k
 * @date : 9:34 2020/5/16
 */
public class 盛最多水的容器_11 {
    /*public int maxArea(int[] height) {
        int res=0;
        int left=0;
        int right=height.length-1;
        while (left<right){
            res=height[left]<height[right]?
                    Math.max(res,(right-left)*height[left++]):
                    Math.max(res,(right-left)*height[right--]);
        }
        return res;
    }*/
    public int maxArea(int[] height) {
        int left=0;
        int right=height.length-1;
        int res=0;

        while (left<right){
            res=(height[left] < height[right])?
                    Math.max(res,(right-left)*height[left++]):
                    Math.max(res,(right-left*height[right--]));
        }
        return res;
    }
}
